home *** CD-ROM | disk | FTP | other *** search
- Path: nyx10.cs.du.edu!not-for-mail
- From: vputz@nyx10.cs.du.edu (Victor Putz)
- Newsgroups: comp.lang.c++
- Subject: Interface/Class design-- guidelines?
- Date: 14 Mar 1996 12:21:23 -0700
- Organization: University of Denver, Math/CS Dept.
- Message-ID: <4i9rjj$t2a@nyx10.cs.du.edu>
- NNTP-Posting-Host: nyx10.nyx.net
- X-Newsreader: NN version 6.5.0 #3 (NOV)
-
- After flailing with C++ for some time, I'm slowly beginning to
- appreciate the benefit of good design (some lessons are slow to
- take). In any case, I feel certain that my "try it and see"
- approach to class design is flawed and was wondering if anyone
- had any pointers to good class/interface design.
-
- I was also intrigued by the bit in "The C++ Programming Language"
- (Stroustrop section 12.4, "Interfaces and implementations") wherein
- Stroustrop asserts that a class X :
-
- class X {
- Y a;
- Z b;
- ...
- };
-
- has problems because "The interface uses the types Y and Z in a way
- that requires the declarations of Y and Z to be known to compile it,"
- and seems to advocate pointer or reference members as a "better choice"
- for significant classes:
-
- class X {
- Y* a;
- Z& b;
- ...
- };
-
- ... since the compiler doesn't have to know much about the class to
- reserve space for a pointer or reference. I'm pretty clear how a
- pointer member could be used for the same effect (allocate it in the
- constructor, don't touch it elsewhere, and deallocate it in the
- destructor) but how could a reference member be useful?
-
- Thanks-->VPutz
-
-